﻿using Microsoft.AspNetCore.Mvc;
using Nasty.Core.LoadParams;
using Nasty.Core.Registry;
using Nasty.SystemModule.Areas.Post.Model;
using Nasty.SystemModule.Areas.Post.Params;
using NetTaste;

namespace Nasty.SystemModule.Post
{
	public interface IPostService : IAutofacRegister
	{
		public Nasty.Core.Entity.System.Post GetPost(string id);

		public List<Nasty.Core.Entity.System.Post> GetPosts(GetPostsParams @params);

        public ResultData<Nasty.Core.Entity.System.Post> SavePost(PostModel model);

		public ResultData<string> DeletePosts(List<string> ids);

        public PageData<Nasty.Core.Entity.System.Post> GetPostPage(GetPostPageParams @params);
    }

	public class PostService : IPostService
	{
		public required IPostRepository PostRepository { get; set; }

		public ResultData<string> DeletePosts(List<string> ids)
		{
			return PostRepository.DeletePosts(ids);
		}

		public Nasty.Core.Entity.System.Post GetPost(string id)
		{
			return PostRepository.GetPost(id);
		}

     
        public PageData<Nasty.Core.Entity.System.Post> GetPostPage(GetPostPageParams @params)
        {
            return PostRepository.GetPostPage(@params);
        }

        public ResultData<Nasty.Core.Entity.System.Post> SavePost(PostModel model)
		{
			return PostRepository.SavePost(model);
		}

        public List<Nasty.Core.Entity.System.Post> GetPosts(GetPostsParams @params)
        {
            return PostRepository.GetPosts(@params);
        }
    }
}
